import React, { Component } from 'react';
import {StyleSheet, Modal, Text, View, TouchableOpacity, ActivityIndicator} from 'react-native';

export default class Loading extends Component {
    constructor() {
        super()
        this.state = {
            info: ''
        }
    }
    componentDidMount() {
        this.setState({
            info: this.props.info || ''
        })
    }
    componentWillReceiveProps = (nextProps) => {
        this.setState({
            info: nextProps.info || ''
        })
    }
    render() {
        return (
            <View style={{ position: 'absolute', top: 0, left: 0, width: '100%', height: '100%' }}>
                {/*模态框*/}
                <Modal
                    animationType={"fade"}
                    transparent={true}
                    visible={true}
                    underlayColor="blue"
                    style={{flex: 1, padding: 0}}
                >
                    <View style={{flex: 1, justifyContent: 'center', alignItems: 'center', backgroundColor: 'rgba(0, 0, 0, 0.5)'}}>
                        <ActivityIndicator size="large" color="#ff7606" />
                        <View style={{paddingTop: 10}}>
                            <Text style={{ fontSize: 14, color: '#ff7606' }}>{this.state.info}</Text>
                        </View>
                    </View>
                </Modal>
            </View>
        )
    }
}
